<!DOCTYPE html>
<html >
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title></title>
		<script src="../../script/mui.min.js"></script>
		<link href="../../css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/CFNetPP_Base.css">
		<script type="text/javascript" src="../../script/echarts.min.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			.listDiv .base_dark_grey {
				color: #000000
			}
			.listDiv .base_grey {
				color: #333333
			}
			.listDiv .base_light_gray {
				color: #666666;
			}
			.listDiv .mui-table-view-cell:after {
				background-color: #EDEDED;
			}
		</style>
	</head>
	<body>
		<ul id="list_view" class="mui-table-view checkapply listDiv" >
			<!--	<li dataid="' + index + '" class="mui-table-view-cell mui-media train_list_cell">
			<div class="mui-media-body">
			<p class="font16 base_dark_grey">
			data.rename1
			</p>
			<p class="mui-ellipsis font14 base_grey width73 top_5">
			comment
			</p>
			<span class=" mui-pull-right font14 base_light_gray timepos">' + getLocalTime(data.instime) + '</span>
			</div>
			</li>-->
		</ul>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="pushdata()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
	</body>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var refreshCount = 0;
		//更新数据条数
		var dataArr = new Array();
		var page = 1;
		var rows = 10;
		var review = 0;
		var school_id = '';
		var company_id = '';
		//未审核
		var time;
		apiready = function() {
			postprogress();
			//判断老师是否是班级管理员
			//			judgeAdministrator();
			loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
			ReceiveNotifi();
		}
		//审核实习报告后，刷新实习报告未审核页面
		function ReceiveNotifi() {
			api.addEventListener({
				name : 'RefreshReportReviewedNotifi'
			}, function(ret, err) {
				loadNewData();
			});
			api.addEventListener({
			    name: 'selectTrainClassNotifi'
			}, function(ret, err) {
			    var value = ret.value;
			    var classid = value.id;
			    company_id = '';
			    if (classid == 0) {
			    	school_id = '';
			    }else{
			    	school_id = classid;
			    }
			    loadNewData();
			});
			api.addEventListener({
			    name: 'selectTrainCompanyNotifi'
			}, function(ret, err) {
			    var value = ret.value;
			    var companyid = value.id;
			    school_id = '';
			    if (companyid == 0) {
			    	company_id = '';
			    }else{
			    	company_id = companyid;
			    }
			    loadNewData();
			});
		}

		function loadData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
				page : page,
				rows : rows,
				reviewstatus : review,//未审核状态的周报列表
				school_id : school_id,
 				company_id : company_id	
			};
			cfnetppPOST(urlGraduationlist, param, true, function(data, status) {
			
				
				api.hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.status == 1) {
						//						document.getElementById("noNet").style.display = "none"
						var dataArray = data.json;
						var list = dataArray.lst;
						if (list != null && list.constructor == Array && list.length > 0) {
							$('#noData').hide();
							refreshCount = list.length;
							var listArr = new Array();
							var htmlString = new String();
							if (page == 1) {
								for (var i = 0; i < list.length; i++) {
									var completion = list[i];
									var data = {
										id : completion.id,
										uid : completion.uid,
										rename1 : completion.rename1,
										instime : completion.instime,
										comments : completion.comments,
										tcomment : completion.tcomment,
										sxtypes : completion.sxtypes,
									};
//									alert('获取数据' + JSON.stringify(data));
									listArr.push(data);
									htmlString += htmlStringWithName(data, i);
								}
								dataArr = listArr;
//								alert(htmlString);
								$('#list_view').html(htmlString);
							} else {
								var oldCount = dataArr.length;
								for (var i = 0; i < list.length; i++) {
									var index = oldCount + i;
									var completion = list[i];
									var data = {
										id : completion.id,
										uid : completion.uid,
										rename1 : completion.rename1,
										instime : completion.instime,
										comments : completion.comments,
										tcomment : completion.tcomment,
										sxtypes : completion.sxtypes,
									};
									listArr.push(data);
									htmlString += htmlStringWithName(data, index);
								}
								dataArr = dataArr.concat(listArr);
								$('#list_view').append(htmlString);
							}
							setupTapCellClick();
						} else {
							if (page == 1) {
								$('#noData').show();
								$('#list_view').html('');
							} else {
								
							}
						}
					} else {
						if (page == 1) {
							$('#list_view').html('');
							$('#noData').show();
						}
					}
				} else {
					$('#noNet').show();
				}
			});
		};
		function pushdata() {
			window.location.reload()
		}

		function loadNewData() {
			page = 1;
			loadData();
			//停止刷新控件
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		function postprogress() {
			api.showProgress({
				style : 'default',
				animationType : 'fade',
				title : '正在请求数据...',
				text : '请稍等...',
				modal : true
			});
		}

		//获取点击条目
		function setupTapCellClick() {
			$('.train_list_cell').unbind('click');
			$('.train_list_cell').click(function() {
				var dataid = $(this).attr('dataid');
				var data = dataArr[parseInt(dataid)];
				var id = parseInt(data.id)
				var rename1 = data.rename1;
				var sxtypes = parseInt(data.sxtypes);
				api.openWin({useWKWebView:true,
					name : 'Teacher_ScoreNoReport',
					url : 'Teacher_ScoreNoReport.html',
					pageParam : {
						repid : id,
						rename1 : rename1,
						sxtypes : sxtypes,
						sourceurl : api.pageParam.sourceurl,
						sourcetitle : api.pageParam.sourcetitle,
					},
					allowEdit : true
				});
			});
		}

		function htmlStringWithName(data, index) {
			var spanComment = CommentisNull(data.tcomments);
			var comment = '';
			if (spanComment == null) {
				spanComment = '请查看此学生实习报告 ';
			} else {
				spanComment = data.tcomment;
			}
			if (spanComment.length > 10) {
				comment = spanComment.substring(0, 10) + '....';
			} else {
				comment = spanComment;
			}
			return '<li dataid="' + index + '" class="mui-table-view-cell mui-media train_list_cell">' 
			   + '<div class="mui-media-body">' + '<p class="font16 base_dark_grey">' + data.rename1 + '</p>' 
			   + '<p class="mui-ellipsis font14 base_grey width73 top_5">' + comment + '</p>' 
			   + '<span class=" mui-pull-right font14 base_light_gray timepos">' + getLocalTime(data.instime) + '</span>' 
			   + '</div>' + '</li>'
		}

		function getNowFormatDate(time) {
			var datetime;
			if (time.length == 10) {
				datetime = parseInt(time) * 1000;
			} else {
				datetime = parseInt(time);
			}
			var date = new Date(datetime);
			var seperator1 = "-";
			var seperator2 = ":";
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			var mm = date.getMinutes();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			if (mm >= 0 && mm <= 9) {
				mm = "0" + mm;
			}
			var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + mm;
			return currentdate;
		}

		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				loadNewData();
			});
		}

		// 上拉加载
		function setPullUpRefresh() {
			api.addEventListener({
				name : 'scrolltobottom'
			}, function(ret, err) {
				//      if (refreshCount >= rows) {
				loadMoreData();
				//  }
			});
		}
	</script>
</html>
